//
//  AMhomeTableViewController.m
//  AMwb
//
//  Created by zhc on 15/11/28.
//  Copyright © 2015年 zhc. All rights reserved.
//

#import "AMhomeTableViewController.h"
#import "UIBarButtonItem+Extension.h"
#import "AMDropdownMeun.h"
#import "AMmenu.h"

@interface AMhomeTableViewController ()<AMDropdownMeunDelegate>

@end

@implementation AMhomeTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
  
    self.navigationItem.rightBarButtonItem=[UIBarButtonItem itemWithtager:self image:@"navigationbar_friendsearch" imageHighlighted:@"navigationbar_friendsearch_highlighted" action:nil];
    
    self.navigationItem.leftBarButtonItem=[UIBarButtonItem itemWithtager:self image:@"navigationbar_pop" imageHighlighted:@"navigationbar_pop_highlighted" action:nil];
    self.navigationItem.title=@"主页";
    
    
    
    
    UIButton *btnView=[[UIButton alloc]init];
    
    btnView.frame=CGRectMake(0, 0, 150, 30);
    //btnView.backgroundColor=[UIColor redColor];
    
    [btnView setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    
    [btnView setTitle:@"主题" forState:UIControlStateNormal];
    [btnView setImage:[UIImage imageNamed:@"navigationbar_arrow_down"] forState:UIControlStateNormal];
    [btnView setImage:[UIImage imageNamed:@"navigationbar_arrow_up"] forState:UIControlStateSelected];
    
    btnView.titleEdgeInsets=UIEdgeInsetsMake(0, 0, 0, 40);
    btnView.imageEdgeInsets=UIEdgeInsetsMake(0, 70, 0, 0);
    
    self.navigationItem.titleView=btnView;
    
    
    [btnView addTarget:self action:@selector(titleClick:) forControlEvents:UIControlEventTouchUpInside];


    
    
    
    
}

- (void)titleClick:(UIButton *)btnView{

    //UIImageView
    //1.创建下拉菜单
    AMDropdownMeun *menu=[AMDropdownMeun menu];
    menu.delegate=self;
    
   // menu.content=[[UITableView alloc]initWithFrame:CGRectMake(0, 0, 0, 100)];
    
  // menu.content=[UIButton buttonWithType:UIButtonTypeContactAdd];
    //2.添加下拉菜单的内容
    menu.content=[[UITableView alloc]initWithFrame:CGRectMake(0, 0, 0, 100)];
    
    AMmenu *vc=[[AMmenu alloc]init];
    vc.view.height=200;
    vc.view.width=150;
    menu.contentController=vc;
//    
//  3.显示
    [menu showFrom:btnView];
    
    
}

#pragma marks-AMDropdownMeunDelegate>的显示方法

- (void)dropdownMeunshow:(AMDropdownMeun *)menu{
    
    
    //4.旋转小箭头
    
    UIButton *btnArrow=(UIButton*)self.navigationItem.titleView;
    btnArrow.selected=NO;
    
    //[btnArrow setImage:[UIImage imageNamed:@"navigationbar_arrow_up"]forState:UIControlStateNormal];

}




#pragma marks-AMDropdownMeunDelegate>的隐藏方法

-(void)dropdownMeunDismiss:(AMDropdownMeun *)menu
{
    UIButton *btnArrow=(UIButton*)self.navigationItem.titleView;
    btnArrow.selected=YES;
    
   // [btnArrow setImage:[UIImage imageNamed:@"navigationbar_arrow_down"]forState:UIControlStateNormal];



}



- (void)friendsearch{


}






@end
